#include <iostream>
#include <string>
#include <cmath>

bool is_prime(int n) {
    if (n <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

std::string closest_prime_number(std::string s) {
    std::string number = "";
    std::string word;
    for (char c : s) {
        if (c == 'zero') {
            number += "0";
        } else if (c == 'one') {
            number += "1";
        } else if (c == 'two') {
            number += "2";
        } else if (c == 'three') {
            number += "3";
        } else if (c == 'four') {
            number += "4";
        } else if (c == 'five') {
            number += "5";
        } else if (c == 'six') {
            number += "6";
        } else if (c == 'seven') {
            number += "7";
        } else if (c == 'eight') {
            number += "8";
        } else if (c == 'nine') {
            number += "9";
        } else {
            return "Wrong input";
        }
    }
    if (number.empty() || number.size() != 3) {
        return "Wrong input";
    }
    int num = std::stoi(number);
    int lower = num - 1;
    int upper = num + 1;
    while (true) {
        if (is_prime(lower)) {
            return std::to_string(lower);
        } else if (is_prime(upper)) {
            return std::to_string(upper);
        }
        lower--;
        upper++;
    }
}

int main() {
    std::string s;
    std::cin >> s;
    std::string result = closest_prime_number(s);
    std::cout << result << std::endl;
    return 0;
}
